Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDP protocol on connect agnhost command #98639

Merged
merged 1 commit into from
Feb 9, 2021

Conversation

knabben
Copy link
Member

@knabben knabben commented Jan 31, 2021

What type of PR is this?
/kind feature

What this PR does / why we need it:
Adding UDP support on agnhost connect subcommand, so we can have standardized tooling for e2e network probe tests.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:
With a host listening on UDP 8000:

./agnhost serve-hostname --udp --http=false --port 8000
$ ./agnhost connect --protocol udp localhost:8000
$ echo $?
0

$ ./agnhost connect --protocol udp localhost:8002  # wrong port
REFUSED: read udp [::1]:51142->[::1]:8002: read: connection refused
$ echo $?
1

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 31, 2021
@k8s-ci-robot
Copy link
Contributor

@knabben: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 31, 2021
@k8s-ci-robot k8s-ci-robot added area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 31, 2021
}
}

if _, err = conn.Write([]byte("hostname\n")); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can't assume the other end knows what hostname means,
this is the problem with UDP, it is connection less, so we need to send something and the other reply in order to know the connection is ok.
What if we add another flag to be able to send data and we default it to hostname or hello

		cmd = []string{"/agnhost", "connect", fmt.Sprintf("%s:%d", addrTo, toPort), "--timeout=1s", "--protocol=udp","--data=hostname"}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, what about --udp-data, since it's only used for UDP?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, sounds much better, but keep it defaulted with some data

parseUDPErrorAndExit(err)
}

var buf = make([]byte, 1024)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have to verify that we actually received some data

n, err := con.Read(buf)
if err != nil {
ret.Error = err
neterr, ok := err.(net.Error)
if ok && neterr.Timeout() {
ret.Status = UDPTimeout
} else if strings.Contains(err.Error(), "connection refused") {
ret.Status = UDPRefused
} else {
ret.Status = UDPError
}
framework.Logf("Poke(%q): %v", url, err)
return ret
}
ret.Response = buf[0:n]
if params.Response != "" && string(ret.Response) != params.Response {
ret.Status = UDPBadResponse
ret.Error = fmt.Errorf("response does not match expected string: %q", string(ret.Response))
framework.Logf("Poke(%q): %v", url, ret.Error)
return ret
}
ret.Status = UDPSuccess
framework.Logf("Poke(%q): success", url)
return ret

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raising an error when readBytes == 0..
looks something that can be controlled on a flag i.e. --wait-response. or even use a --udp-request | --udp-response..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you don't receive any bytes you can not known that the other side is receiving packets.
This is the same we discussed in slack regarding netcat, it just checks that the packet goes out, it doesn't mean it has been received, there is no ACK... 🤷

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can return an error more descriptive "NO DATA RECEIVED" , and clarifiy that we can't guarantee the port is open


func init() {
CmdConnect.Flags().DurationVar(&timeout, "timeout", time.Duration(0), "Maximum time before returning an error")
CmdConnect.Flags().StringVar(&protocol, "protocol", "tcp", "The protocol to use to perform the connection, can be tcp or sctp")
CmdConnect.Flags().StringVar(&protocol, "protocol", "tcp", "The protocol to use to perform the connection, can be tcp, udp or sctp")
CmdConnect.Flags().StringVar(&udpData, "udp-data", "", "The UDP payload send to the server")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should put some data as default, "hello" or "hostname" can be valid since are used in our tests in a number of cases, I think hostname is used in more places

@aojea
Copy link
Member

aojea commented Feb 1, 2021

/lgtm
/assign @claudiubelu @spiffxp

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 1, 2021
}

// ensure the response from UDP server
if readBytes == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, basically, we just have to make sure that the UDP server sends us some data back, the content of which is unimportant, right?

Copy link
Member

@aojea aojea Feb 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the more general approach .... we can complicate it more and add an option to match the answer ... but if we don´t check that at least we receive something we can´t know if the port was open or not

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claudiubelu
Copy link
Contributor

/lgtm

@dims
Copy link
Member

dims commented Feb 4, 2021

@knabben looks like we are adding a new "feature", please update test/images/agnhost/VERSION

@aojea
Copy link
Member

aojea commented Feb 4, 2021

yeah, I forget that, sorry, I think you have to bump these 3 files:

build/dependencies.yaml
test/images/agnhost/VERSION
test/images/agnhost/agnhost.go

@knabben
Copy link
Member Author

knabben commented Feb 4, 2021

I was about to ask what is the release process :) thanks @aojea @dims

@dims
Copy link
Member

dims commented Feb 5, 2021

/hold

some more files need to be updated.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 5, 2021
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 5, 2021
@knabben
Copy link
Member Author

knabben commented Feb 5, 2021

@dims bumped the files. Is this something that needs to be changed as well? https://github.com/kubernetes/kubernetes/blob/ead0271fcfbf0ee482e14151f338a6590e38e3f5/build/dependencies.yaml#L12

@@ -1,7 +1,7 @@
dependencies:
# agnhost: bump this one first
- name: "agnhost"
version: "2.27"
version: "2.28"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change this just yet (since this version does not exist in the gcr repository)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh.. the dependencies job is failing with a test/images/agnhost/VERSION mismatch.

Copy link
Member

@aojea aojea Feb 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dims I think that is correct

agnhost: bump this one first

there is another place that is the one that has to be bumped later, once the promotion has been done

@@ -51,7 +51,7 @@ import (
func main() {
rootCmd := &cobra.Command{
Use: "app",
Version: "2.27",
Version: "2.28",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is correct, this has to be bumped first so we can promote it later

@aojea
Copy link
Member

aojea commented Feb 7, 2021

🤔 it fails

hack/make-rules/../../hack/verify-vendor.sh
make: *** [Makefile:128: verify] Error 1
+ EXIT_VALUE=2
+ set +o xtrace

you can run it locally to find out what is the problem ...

@knabben
Copy link
Member Author

knabben commented Feb 7, 2021

locally the command pass, let me rerun this again here.

/test pull-kubernetes-dependencies

@knabben
Copy link
Member Author

knabben commented Feb 7, 2021

/test pull-kubernetes-bazel-test

@dims
Copy link
Member

dims commented Feb 9, 2021

/hold cancel
/approve

please get an /lgtm from @aojea :) you main need additional approvals for the build/ directory

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 9, 2021
@aojea
Copy link
Member

aojea commented Feb 9, 2021

/lgtm
/assign @spiffxp

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 9, 2021
@claudiubelu
Copy link
Contributor

/approve

Copy link
Member

@spiffxp spiffxp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve
/lgtm
Now that connect supports N=3 protocols, I think it'd be appropriate to refactor instead of continuing to copy-paste. It feels to me like there's plenty of untested room for subtle bugs between impls, but I won't block for that.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: claudiubelu, dims, knabben, spiffxp

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 9, 2021
@aojea
Copy link
Member

aojea commented Feb 9, 2021

Now that connect supports N=3 protocols, I think it'd be appropriate to refactor instead of continuing to copy-paste. It feels to me like there's plenty of untested room for subtle bugs between impls, but I won't block for that.

yeah, but the networking tests are a minefield, and this only probes for connectivity , i.e. I submit something the other side replays something, there are other tests that need to check the content of the replay, i.e. to verify that the the pod belong to the expected hostname, so this is no a replacement for those.

@k8s-ci-robot k8s-ci-robot merged commit ab5a8c4 into kubernetes:master Feb 9, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Feb 9, 2021
@knabben knabben deleted the udp-connect-agnhost branch February 9, 2021 18:29
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants